<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>easyFindNumber</title>
    <link rel="stylesheet" href="/css/index.css"/>
    <script src="/node_modules/jquery/dist/jquery.min.js"></script>
</head>
<body>
<nav class="navbar navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" href="https://github.com/WittBulter/easyFindNumber" target="_blank">GITHUB</a>
        </div>
    </div>
</nav>
<div class="jumbotron">
    <form novalidate>
        <div class="input-group search-input">
            <input type="text" class="form-control" placeholder="更多资源添加中..."/>
            <span class="input-group-btn">
                <button class="btn btn-info" type="button">搜索</button>
             </span>
        </div>
    </form>

</div>

<div class="container container-min">
    <div class="row">
        <div class="col-lg-6">
            <div class="panel  panel-success">
            <div class="panel-heading">网盘资源</div>
                <ul class="list-group" id="pan">
                </ul>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="panel  panel-success">
                <div class="panel-heading">磁力链接1</div>
                <ul class="list-group" id="magnet1">
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-6">
            <div class="panel  panel-success">
                <div class="panel-heading">磁力链接2</div>
                <ul class="list-group" id="magnet2">
                </ul>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="panel  panel-success">
                <div class="panel-heading">磁力链接3</div>
                <ul class="list-group" id="magnet3">
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-6">
            <div class="panel  panel-success">
                <div class="panel-heading">磁力链接4</div>
                <ul class="list-group" id="magnet4">
                </ul>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="panel  panel-success">
                <div class="panel-heading">磁力链接5</div>
                <ul class="list-group" id="magnet5">
                </ul>
            </div>
        </div>
    </div>

</div>

<footer>
    <div class="container">
        <p>本项目源码遵循 MIT开源协议</p>
    </div>
</footer>
<script>
    $(function () {
        var li = '<li class="list-group-item"><span></span><button class="btn btn-default btn-xs fr">copy</button></li>';
        var list = $('ul.list-group');
        var getNumber = function (code, dom) {
            $.get('/magnet',{code:code,name:dom}, function (data) {
                updateDOM(data.data, dom)
            },'json')
        };
        var updateDOM = function (data, dom) {
            var dom = $('#' + dom);
            dom.slideUp();
            data.forEach(function (v, i) {
                dom.append($(li).find('span').text(v.link).parent().find('button').text((v.size?v.size:'未知')).parent())
            })
            dom.slideDown();
        }
        $('.btn-info').on('click', function () {
            var code = $ ('.form-control').val ();
            if (! code) {
                return alert('请输入查询串')
            }
            list.slideUp();
            list.children('li').remove()
            getNumber(code,'pan')
            getNumber(code,'magnet1')
            getNumber(code,'magnet2')
            getNumber(code,'magnet3')
            getNumber(code,'magnet4')
            getNumber(code,'magnet5')
        })
        list.on('click','li>button', function () {
            $(this).toggleClass('active').parent().find('span').toggleClass('show')
        })
    })
</script>
</body>
</html>